package com.onetoall.yjt;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * Created by DELL on 2017/1/5.
 */

public class InnerAdapter extends BaseAdapter {
    private  Context context;
    private List<String> datas;

    public InnerAdapter(Context context, List<String> datas){
            this.context = context;
        this.datas = datas;
    }
    @Override
    public int getCount() {
        return datas.size() ;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
       MyHolder holder = null;
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.item_inner,null);
            holder = new  MyHolder();
            holder.textView = (TextView) convertView.findViewById(R.id.tv_inner_content);
            convertView.setTag(holder);
        }else {
            holder = (MyHolder) convertView.getTag();
        }
        setDatas(position,holder);
        return convertView;
    }

    class MyHolder{
        public TextView textView;
    }
    public void setDatas(int position, MyHolder holder){
        holder.textView.setText(datas.get(position));
    }
}
